home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume2 / aplictns / matlab / help.2 < prev    next >
Internet Message Format  |  1988-11-03  |  31KB

  1. Path: xanth!nic.MR.NET!hal!cwjcc!mailrus!bbn!ulowell!page
  2. From: page@swan.ulowell.edu (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v02i049:  matlab - matrix laboratory, Part09/11 (help02/02)
  5. Message-ID: <10024@swan.ulowell.edu>
  6. Date: 2 Nov 88 21:52:41 GMT
  7. Organization: University of Lowell, Computer Science Dept.
  8. Lines: 394
  9. Approved: page@swan.ulowell.edu
  10.  
  11. Submitted-by: strovink%galaxy-43@afit-ab.arpa (Mark A. Strovink)
  12. Posting-number: Volume 2, Issue 49
  13. Archive-name: applications/matlab/help.2
  14.  
  15. #    This is a shell archive.
  16. #    Remove everything above and including the cut line.
  17. #    Then run the rest of the file through sh.
  18. #----cut here-----cut here-----cut here-----cut here----#
  19. #!/bin/sh
  20. # shar:    Shell Archiver
  21. #    Run the following text with /bin/sh to create:
  22. #    help-2
  23. # This archive created: Wed Nov  2 16:19:36 1988
  24. cat << \SHAR_EOF > help-2
  25.       FOR J = 1:N, V = A(:,J); ...  except J is also set here.                  
  26.                                                                                 
  27. FUN   For matrix arguments  X , the  functions  SIN,  COS,  ATAN,               
  28.       SQRT,  LOG,  EXP and X**p are computed using eigenvalues  D               
  29.       and eigenvectors  V .  If  <V,D> =  EIG(X)   then   f(X)  =               
  30.       V*f(D)/V  .   This method may give inaccurate results if  V               
  31.       is badly conditioned.  Some idea of  the  accuracy  can  be               
  32.       obtained by comparing  X**1  with  X .                                    
  33.       For vector arguments,  the  function  is  applied  to  each               
  34.       component.                                                                
  35.                                                                                 
  36. HESS  Hessenberg form.  The Hessenberg form of a matrix  is  zero               
  37.       below the first subdiagonal.  If the matrix is symmetric or               
  38.       Hermitian,  the  form  is  tridiagonal.   <P,H>  =  HESS(A)               
  39.       produces  a  unitary  matrix P and a Hessenberg matrix H so               
  40.       that A = P*H*P'.  By itself, HESS(A) returns H.                           
  41.                                                                                 
  42. HILB  Inverse Hilbert matrix.  HILB(N)  is the inverse of  the  N               
  43.       by  N   matrix  with elements  1/(i+j-1), which is a famous               
  44.       example of a badly conditioned matrix.  The result is exact               
  45.       for  N  less than about 15, depending upon the computer.                  
  46.                                                                                 
  47. IF    Conditionally execute statements.  Simple form...                         
  48.       IF expression rop expression, statements                                  
  49.       where rop is =, <, >, <=, >=, or  <>  (not  equal)  .   The               
  50.       statements  are  executed  once if the indicated comparison               
  51.       between the real parts of the first components of  the  two               
  52.       expressions  is true, otherwise the statements are skipped.               
  53.       Example.                                                                  
  54.       IF ABS(I-J) = 1, A(I,J) = -1;                                             
  55.       More complicated forms use END in the same way it  is  used               
  56.       with FOR and WHILE and use ELSE as an abbreviation for END,               
  57.       IF expression not rop expression .  Example                               
  58.       FOR I = 1:N, FOR J = 1:N, ...                                             
  59.          IF I = J, A(I,J) = 2; ELSE IF ABS(I-J) = 1, A(I,J) = -1; ...           
  60.          ELSE A(I,J) = 0;                                                       
  61.       An easier way to accomplish the same thing is                             
  62.       A = 2*EYE(N);                                                             
  63.       FOR I = 1:N-1, A(I,I+1) = -1; A(I+1,I) = -1;                              
  64.                                                                                 
  65. IMAG  IMAG(X)  is the imaginary part of  X .                                    
  66.                                                                                 
  67. INV   INV(X)  is the inverse of the square matrix  X .  A warning               
  68.       message  is  printed  if   X   is  badly  scaled  or nearly               
  69.       singular.                                                                 
  70.                                                                                 
  71. KRON  KRON(X,Y) is the Kronecker tensor product of X and Y  .  It               
  72.       is  also  denoted by X .*. Y . The result is a large matrix               
  73.       formed by taking all possible products between the elements               
  74.       of  X  and  those  of Y . For example, if X is 2 by 3, then               
  75.       X .*. Y is                                                                
  76.                                                                                 
  77.             < x(1,1)*Y  x(1,2)*Y  x(1,3)*Y                                      
  78.               x(2,1)*Y  x(2,2)*Y  x(2,3)*Y >                                    
  79.                                                                                 
  80.       The five-point discrete Laplacian for an n-by-n grid can be               
  81.       generated by                                                              
  82.                                                                                 
  83.             T = diag(ones(n-1,1),1);  T = T + T';  I = EYE(T);                  
  84.             A = T.*.I + I.*.T - 4*EYE;                                          
  85.                                                                                 
  86.       Just  in  case  they  might  be  useful,  MATLAB   includes               
  87.       constructions called Kronecker tensor quotients, denoted by               
  88.       X ./. Y and X .\. Y .  They are obtained by  replacing  the               
  89.       elementwise multiplications in X .*. Y with divisions.                    
  90.                                                                                 
  91. LINES An internal count is kept of the number of lines of  output               
  92.       since  the  last  input.   Whenever this count approaches a               
  93.       limit, the  user  is  asked  whether  or  not  to  suppress               
  94.       printing  until the next input.  Initially the limit is 25.               
  95.       LINES(N) resets the limit to N .                                          
  96.                                                                                 
  97. LOAD  LOAD('file') retrieves all the variables from  the  file  .               
  98.       See  FILE  and  SAVE for more details.  To prepare your own               
  99.       file for LOADing, change the READs to WRITEs  in  the  code               
  100.       given under SAVE.                                                         
  101.                                                                                 
  102. LOG   LOG(X)  is the  natural  logarithm  of   X  .   See  FUN  .               
  103.       Complex results are produced if  X  is not positive, or has               
  104.       nonpositive eigenvalues.                                                  
  105.                                                                                 
  106. LONG  Determine output format.   All  computations  are  done  in               
  107.       complex arithmetic and double precision if it is available.               
  108.       SHORT and  LONG  merely  switch  between  different  output               
  109.       formats.                                                                  
  110.       SHORT    Scaled fixed point format with about 5 digits.                   
  111.       LONG     Scaled fixed point format with about 15 digits.                  
  112.       SHORT E  Floating point format with about 5 digits.                       
  113.       LONG E   Floating point format with about 15 digits.                      
  114.       LONG Z   System dependent format, often hexadecimal.                      
  115.                                                                                 
  116. LU    Factors from Gaussian elimination.  <L,U> = LU(X)  stores a               
  117.       upper triangular matrix in  U  and a 'psychologically lower               
  118.       triangular matrix', i.e. a product of lower triangular  and               
  119.       permutation matrices, in L , so that  X = L*U .  By itself,               
  120.       LU(X) returns the output from CGEFA .                                     
  121.                                                                                 
  122. MACRO The macro facility involves text and inward pointing  angle               
  123.       brackets.  If  STRING  is  the  source  text for any MATLAB               
  124.       expression or statement, then                                             
  125.             t = 'STRING';                                                       
  126.       encodes the text as a vector of integers  and  stores  that               
  127.       vector in  t .  DISP(t) will print the text and                           
  128.             >t<                                                                 
  129.       causes the text to be interpreted, either as a statement or               
  130.       as a factor in an expression.  For example                                
  131.             t = '1/(i+j-1)';                                                    
  132.             disp(t)                                                             
  133.             for i = 1:n, for j = 1:n, a(i,j) = >t<;                             
  134.       generates the Hilbert matrix of order n.                                  
  135.       Another example showing indexed text,                                     
  136.             S = <'x = 3            '                                            
  137.                  'y = 4            '                                            
  138.                  'z = sqrt(x*x+y*y)'>                                           
  139.             for k = 1:3, >S(k,:)<                                               
  140.       It is necessary that the strings making up  the  "rows"  of               
  141.       the "matrix"  S  have the same lengths.                                   
  142.                                                                                 
  143. MAGIC Magic square.  MAGIC(N) is an N  by  N  matrix  constructed               
  144.       from  the integers 1 through N**2 with equal row and column               
  145.       sums.                                                                     
  146.                                                                                 
  147. NORM  For matrices..                                                            
  148.       NORM(X)  is the largest singular value of  X .                            
  149.       NORM(X,1)  is the 1-norm of  X .                                          
  150.       NORM(X,2)  is the same as NORM(X) .                                       
  151.       NORM(X,'INF')  is the infinity norm of  X .                               
  152.       NORM(X,'FRO')  is the F-norm, i.e.  SQRT(SUM(DIAG(X'*X))) .               
  153.       For vectors..                                                             
  154.       NORM(V,P) = (SUM(V(I)**P))**(1/P) .                                       
  155.       NORM(V) = NORM(V,2) .                                                     
  156.       NORM(V,'INF') = MAX(ABS(V(I))) .                                          
  157.                                                                                 
  158. ONES  All ones.  ONES(N)  is an N by N matrix of ones.  ONES(M,N)               
  159.       is an M by N matrix of ones .  ONES(A)  is the same size as               
  160.       A  and all ones .                                                         
  161.                                                                                 
  162. ORTH  Orthogonalization.   Q  =  ORTH(X)   is   a   matrix   with               
  163.       orthonormal  columns,  i.e. Q'*Q = EYE, which span the same               
  164.       space as the columns of  X .                                              
  165.                                                                                 
  166. PINV  Pseudoinverse.  X = PINV(A) produces a matrix   X   of  the               
  167.       same  dimensions as  A' so that  A*X*A = A , X*A*X = X  and               
  168.       AX  and  XA  are Hermitian .  The computation is  based  on               
  169.       SVD(A)  and  any  singular values less than a tolerance are               
  170.       treated   as    zero.     The    default    tolerance    is               
  171.       NORM(SIZE(A),'inf')*NORM(A)*EPS.   This  tolerance  may  be               
  172.       overridden with X = PINV(A,tol).  See RANK.                               
  173.                                                                                 
  174. PLOT  PLOT(X,Y) produces a plot of  the  elements  of  Y  against               
  175.       those  of X . PLOT(Y) is the same as PLOT(1:n,Y) where n is               
  176.       the  number  of   elements   in   Y   .    PLOT(X,Y,P)   or               
  177.       PLOT(X,Y,p1,...,pk)  passes the optional parameter vector P               
  178.       or scalars p1 through pk to the plot routine.  The  default               
  179.       plot  routine  is a crude printer-plot. It is hoped that an               
  180.       interface to local graphics equipment can be provided.                    
  181.       An interesting example is                                                 
  182.             t = 0:50;                                                           
  183.             PLOT( t.*cos(t), t.*sin(t) )                                        
  184.                                                                                 
  185. POLY  Characteristic polynomial.                                                
  186.       If  A  is an N by N matrix, POLY(A) is a column vector with               
  187.       N+1   elements   which   are   the   coefficients   of  the               
  188.       characteristic polynomial,  DET(lambda*EYE - A) .                         
  189.       If V is a vector, POLY(V) is a vector  whose  elements  are               
  190.       the  coefficients  of  the  polynomial  whose roots are the               
  191.       elements of V .  For vectors, ROOTS and  POLY  are  inverse               
  192.       functions  of  each  other,  up  to  ordering, scaling, and               
  193.       roundoff error.                                                           
  194.       ROOTS(POLY(1:20)) generates Wilkinson's famous example.                   
  195.                                                                                 
  196. PRINT PRINT('file',X) prints X on  the  file  using  the  current               
  197.       format determined by SHORT, LONG Z, etc.  See FILE.                       
  198.                                                                                 
  199. PROD  PROD(X)  is the product of all the elements of  X .                       
  200.                                                                                 
  201. QR    Orthogonal-triangular decomposition.                                      
  202.       <Q,R> = QR(X)  produces an upper triangular  matrix   R  of               
  203.       the  same dimension as  X  and a unitary matrix  Q  so that               
  204.       X = Q*R .                                                                 
  205.       <Q,R,E> = QR(X)  produces a  permutation  matrix   E  ,  an               
  206.       upper  triangular  R  with decreasing diagonal elements and               
  207.       a unitary  Q  so that  X*E = Q*R .                                        
  208.       By itself, QR(X) returns the output of CQRDC .  TRIU(QR(X))               
  209.       is R .                                                                    
  210.                                                                                 
  211. RAND  Random numbers and matrices.  RAND(N)  is an N by N  matrix               
  212.       with  random  entries.  RAND(M,N)  is an M by N matrix with               
  213.       random entries.  RAND(A)  is the same size as   A  .   RAND               
  214.       with no arguments is a scalar whose value changes each time               
  215.       it is referenced.                                                         
  216.       Ordinarily,  random numbers are  uniformly  distributed  in               
  217.       the  interval  (0.0,1.0)  .   RAND('NORMAL')  switches to a               
  218.       normal distribution  with  mean  0.0  and  variance  1.0  .               
  219.       RAND('UNIFORM')  switches back to the uniform distribution.               
  220.       RAND('SEED') returns the current value of the seed for  the               
  221.       generator.    RAND('SEED',n)   sets   the   seed   to  n  .               
  222.       RAND('SEED',0) resets the seed to 0, its value when  MATLAB               
  223.       is first entered.                                                         
  224.                                                                                 
  225. RANK  Rank.  K = RANK(X) is the number of singular values  of   X               
  226.       that are larger than NORM(SIZE(X),'inf')*NORM(X)*EPS.                     
  227.       K = RANK(X,tol) is the number of singular values of  X that               
  228.       are larger than tol .                                                     
  229.                                                                                 
  230. RCOND RCOND(X)   is  an  estimate  for  the  reciprocal  of   the               
  231.       condition  of   X   in  the  1-norm obtained by the LINPACK               
  232.       condition estimator.  If  X  is well conditioned,  RCOND(X)               
  233.       is  near  1.0  .   If  X  is badly conditioned, RCOND(X) is               
  234.       near 0.0 .                                                                
  235.       <R, Z> = RCOND(A) sets  R  to RCOND(A) and also produces  a               
  236.       vector  Z so that                                                         
  237.                  NORM(A*Z,1) = R*NORM(A,1)*NORM(Z,1)                            
  238.       So, if RCOND(A) is small, then  Z  is an  approximate  null               
  239.       vector.                                                                   
  240.                                                                                 
  241. RAT   An experimental  function  which  attempts  to  remove  the               
  242.       roundoff   error  from  results  that  should  be  "simple"               
  243.       rational numbers.                                                         
  244.       RAT(X) approximates each  element  of   X  by  a  continued               
  245.       fraction of the form                                                      
  246.                                                                                 
  247.                 a/b = d1 + 1/(d2 + 1/(d3 + ... + 1/dk))                         
  248.                                                                                 
  249.       with k <= len, integer di and abs(di) <= max .  The default               
  250.       values of the parameters are len = 5 and max = 100.                       
  251.       RAT(len,max) changes the default values.  Increasing either               
  252.       len or max increases the number of possible fractions.                    
  253.       <A,B> = RAT(X) produces integer matrices A and B so that                  
  254.                                                                                 
  255.                 A ./ B  =  RAT(X)                                               
  256.                                                                                 
  257.       Some examples:                                                            
  258.                                                                                 
  259.             long                                                                
  260.             T = hilb(6), X = inv(T)                                             
  261.             <A,B> = rat(X)                                                      
  262.             H = A ./ B, S = inv(H)                                              
  263.                                                                                 
  264.             short e                                                             
  265.             d = 1:8,  e = ones(d),  A = abs(d'*e - e'*d)                        
  266.             X = inv(A)                                                          
  267.             rat(X)                                                              
  268.             display(ans)                                                        
  269.                                                                                 
  270.                                                                                 
  271. REAL  REAL(X)  is the real part of  X .                                         
  272.                                                                                 
  273. RETURN  From the terminal, causes return to the operating  system               
  274.       or  other  program  which  invoked  MATLAB.  From inside an               
  275.       EXEC, causes  return  to  the  invoking  EXEC,  or  to  the               
  276.       terminal.                                                                 
  277.                                                                                 
  278. RREF  RREF(A) is the reduced row echelon form of the  rectangular               
  279.       matrix.  RREF(A,B) is the same as RREF(<A,B>) .                           
  280.                                                                                 
  281. ROOTS Find polynomial roots.  ROOTS(C)  computes the roots of the               
  282.       polynomial  whose  coefficients  are  the  elements  of the               
  283.       vector  C .  If  C  has  N+1  components, the polynomial is               
  284.       C(1)*X**N + ... + C(N)*X + C(N+1) .  See POLY.                            
  285.                                                                                 
  286. ROUND ROUND(X)  rounds  the  elements  of   X   to  the   nearest               
  287.       integers.                                                                 
  288.                                                                                 
  289. SAVE  SAVE('file') stores all the current variables in a file.                  
  290.       SAVE('file',X) saves only X .  See FILE .                                 
  291.       The variables may be retrieved later by LOAD('file') or  by               
  292.       your  own program using the following code for each matrix.               
  293.       The lines involving XIMAG may be eliminated  if  everything               
  294.       is known to be real.                                                      
  295.                                                                                 
  296.             attach lunit to 'file'                                              
  297.             REAL or DOUBLE PRECISION XREAL(MMAX,NMAX)                           
  298.             REAL or DOUBLE PRECISION XIMAG(MMAX,NMAX)                           
  299.             READ(lunit,101) ID,M,N,IMG                                          
  300.             DO 10 J = 1, N                                                      
  301.                READ(lunit,102) (XREAL(I,J), I=1,M)                              
  302.                IF (IMG .NE. 0) READ(lunit,102) (XIMAG(I,J),I=1,M)               
  303.          10 CONTINUE                                                            
  304.                                                                                 
  305.       The formats used are system dependent.  The  following  are               
  306.       typical.     See    SUBROUTINE   SAVLOD   in   your   local               
  307.       implementation of MATLAB.                                                 
  308.                                                                                 
  309.         101 FORMAT(4A1,3I4)                                                     
  310.         102 FORMAT(4Z18)                                                        
  311.         102 FORMAT(4O20)                                                        
  312.         102 FORMAT(4D25.18)                                                     
  313.                                                                                 
  314. SCHUR Schur decomposition.  <U,T> = SCHUR(X)  produces  an  upper               
  315.       triangular  matrix   T , with the eigenvalues of  X  on the               
  316.       diagonal, and a unitary matrix  U so that  X =  U*T*U'  and               
  317.       U'*U = EYE .  By itself, SCHUR(X) returns  T .                            
  318.                                                                                 
  319. SHORT See LONG .                                                                
  320.                                                                                 
  321. SEMI  Semicolons at the end of  lines  will  cause,  rather  than               
  322.       suppress,  printing.   A  second  SEMI restores the initial               
  323.       interpretation.                                                           
  324.                                                                                 
  325. SIN   SIN(X)  is the sine of  X .  See FUN .                                    
  326.                                                                                 
  327. SIZE  If X is an M by N matrix, then SIZE(X) is <M, N> .                        
  328.       Can also be used with a multiple assignment,                              
  329.             <M, N> = SIZE(X) .                                                  
  330.                                                                                 
  331. SQRT  SQRT(X)  is the square root of  X .   See  FUN  .   Complex               
  332.       results  are  produced  if   X   is  not  positive,  or has               
  333.       nonpositive eigenvalues.                                                  
  334.                                                                                 
  335. STOP  Use EXIT instead.                                                         
  336.                                                                                 
  337. SUM   SUM(X)   is  the  sum  of  all  the  elements   of    X   .               
  338.       SUM(DIAG(X))  is the trace of  X .                                        
  339.                                                                                 
  340. SVD   Singular value decomposition.  <U,S,V> = SVD(X)  produces a               
  341.       diagonal  matrix  S , of the same dimension as  X  and with               
  342.       nonnegative diagonal  elements  in  decreasing  order,  and               
  343.       unitary matrices  U  and  V  so that  X = U*S*V' .                        
  344.       By itself, SVD(X) returns a vector containing the  singular               
  345.       values.                                                                   
  346.       <U,S,V>   =   SVD(X,0)   produces   the   "economy    size"               
  347.       decomposition.   If  X  is m by n with m > n, then only the               
  348.       first n columns of U are computed and S is n by n .                       
  349.                                                                                 
  350. TRIL  Lower triangle.  TRIL(X) is the lower triangular part of X.               
  351.       TRIL(X,K) is the elements on and below the K-th diagonal of               
  352.       X.  K = 0 is the main diagonal, K > 0  is  above  the  main               
  353.       diagonal and K < 0 is below the main diagonal.                            
  354.                                                                                 
  355. TRIU  Upper triangle.  TRIU(X) is the upper triangular part of X.               
  356.       TRIU(X,K) is the elements on and above the K-th diagonal of               
  357.       X.  K = 0 is the main diagonal, K > 0  is  above  the  main               
  358.       diagonal and K < 0 is below the main diagonal.                            
  359.                                                                                 
  360. USER  Allows personal  Fortran  subroutines  to  be  linked  into               
  361.       MATLAB .  The subroutine should have the heading                          
  362.                                                                                 
  363.                SUBROUTINE USER(A,M,N,S,T)                                       
  364.                REAL or DOUBLE PRECISION A(M,N),S,T                              
  365.                                                                                 
  366.       The MATLAB statement  Y = USER(X,s,t)  results in a call to               
  367.       the  subroutine with a copy of the matrix  X  stored in the               
  368.       argument  A , its column and row dimensions in  M  and  N ,               
  369.       and  the scalar parameters  s  and  t  stored in  S  and  T               
  370.       . If  s and t  are omitted, they are set to  0.0  .   After               
  371.       the  return,   A  is stored in  Y .  The dimensions  M  and               
  372.       N  may be reset within the subroutine.  The statement  Y  =               
  373.       USER(K)  results in a call with M = 1, N = 1  and  A(1,1) =               
  374.       FLOAT(K) .  After the subroutine has been written, it  must               
  375.       be compiled and linked to the MATLAB object code within the               
  376.       local operating system.                                                   
  377.                                                                                 
  378. WHAT  Lists commands and functions currently available.                         
  379.                                                                                 
  380. WHILE Repeat statements an indefinite number of times.                          
  381.       WHILE expr rop expr, statement, ..., statement, END                       
  382.       where rop is =, <, >, <=, >=, or <> (not equal) .  The  END               
  383.       at  the end of a line may be omitted.  The comma before the               
  384.       END may also be omitted.  The commas  may  be  replaced  by               
  385.       semicolons   to   avoid   printing.    The  statements  are               
  386.       repeatedly executed as long  as  the  indicated  comparison               
  387.       between  the  real parts of the first components of the two               
  388.       expressions is true.   Example  (assume  a  matrix   A   is               
  389.       already defined).                                                         
  390.       E = 0*A; F = E + EYE; N = 1;                                              
  391.       WHILE NORM(E+F-E,1) > 0, E = E + F; F = A*F/N; N = N + 1;                 
  392.       E                                                                         
  393.                                                                                 
  394. WHO   Lists current variables.                                                  
  395.                                                                                 
  396. WHY   Provides succinct answers to any questions.                               
  397.                                                                                 
  398. //                                                                              
  399. SHAR_EOF
  400. #    End of shell archive
  401. exit 0
  402. -- 
  403. Bob Page, U of Lowell CS Dept.  page@swan.ulowell.edu  ulowell!page
  404. Have five nice days.
  405.